home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows Expert
/
Windows Expert.iso
/
communic
/
globlwin.zip
/
DOCGLBLS.WIN
Wrap
Text File
|
1991-05-22
|
7KB
|
225 lines
"
Document your globals, SHOPTALK newsletter Mar/Apr issue. -- /V Windows version --
Copyright 1991 Shoptalk Systems
This file may be distributed freely provided to charge is made except
for the cost of media and/or transportation.
To install this into your Smalltalk/V Windows
image, evaluate the following expression:
| drive |
drive := Prompter prompt: 'Enter drive letter to read' default: (String with: Disk drive).
(File pathName: drive, ':docglbls.win') fileIn
"
Smalltalk at: #BaseKeys put: Dictionary new ;
at: #Username put: (Prompter prompt: 'What is your name?' default: 'noname') .
Smalltalk keys asSortedCollection do: [ :each | BaseKeys at: each put: 'base' ] !
DictionaryInspector subclass: #SmalltalkInspector
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: '' !
!SmalltalkInspector class methods ! !
!SmalltalkInspector methods !
comment
"Private - Answer the comment that is associated
with the selected key."
instIndex isNil
ifTrue: [^String new].
^(BaseKeys at: (instList at: instIndex) key)!
comment: textPane
"Private - Answer the comment that is associated
with the selected key."
instIndex isNil
ifTrue: [^String new].
^textPane contents: (BaseKeys at: (instList at: instIndex) key)!
comment: aString from: aDispatcher
"Private - Compile and evaluate aString. Replace
the selected instance variable with the result
of the evaluation. Answer true if there is no
compilation error, else notify aDispatcher as
to the error and answer false."
| result |
instIndex isNil
ifTrue: [^false].
BaseKeys
at: (instList at: instIndex) key
put: aString.
self changed: #instance.
^true!
commentFrom: textPane
"Private - Compile and evaluate aString. Replace
the selected instance variable with the result
of the evaluation. Answer true if there is no
compilation error, else notify aDispatcher as
to the error and answer false."
| result aString |
aString := textPane contents.
instIndex isNil
ifTrue: [^false].
BaseKeys
at: (instList at: instIndex) key
put: aString.
self changed: #instance.
textPane modified: false.
^true!
inspectMenu
"Private - Answer the dictionary
inspector list pane menu."
^Menu
labels: 'remove\inspect\add\print' withCrs
lines: Array new
selectors: #(remove inspectSelection add print)!
instVarList
"Private - Answer an OrderedCollection of
key strings for the list pane."
^instList
inject: OrderedCollection new
into: [ :list :assoc |
(BaseKeys at: assoc key) = 'base'
ifTrue: [ list add: ' ', assoc value ]
ifFalse: [ list add: '*', assoc value ].
list
]!
instVarList: pane
"Private - Answer an OrderedCollection of
key strings for the list pane."
pane contents: (instList
inject: OrderedCollection new
into: [ :list :assoc |
(BaseKeys at: assoc key) = 'base'
ifTrue: [ list add: ' ', assoc value ]
ifFalse: [ list add: '*', assoc value ].
list
])!
openOn: anObject
"Open an inspector window on anObject. Define
the pane sizes and behavior, and shedule the
window."
| commentPane |
object := anObject.
instPane := TextPane new
owner: self;
when: #getContents perform: #instance:;
when: #save perform: #accept:;
framingRatio: ((1/3) @ 0
extent: (2/3) @ (4/5)).
commentPane := TextPane new
model: self;
when: #getContents perform: #comment:;
when: #save perform: #commentFrom:;
"change: #comment:from:; "
framingRatio: (0 @ (4/5)
extent: 1 @ (1/5)).
self
label: 'Smalltalk SystemDictionary' ;
owner: self.
self addSubpane:
(ListPane new
when: #getMenu perform: #inspectMenu:;
model: self;
when: #getContents perform: #instVarList:;
when: #select perform: #selectInstance:;
when: #doubleClickSelect perform: #inspectSelection:;
framingRatio: (
0@0 extent: (1/3) @ (4/5))).
self addSubpane: instPane.
self addSubpane: commentPane.
self setInstList.
self openWindow!
print
"send a summary to the printer of BaseKeys values that
contain comments. cg"
| pStream |
pStream := WriteStream on: String new.
pStream nextPutAll: 'Globals Summary, ', Date today printString.
pStream cr ; cr.
BaseKeys keys asSortedCollection do: [ :each |
(BaseKeys at: each) <> 'base'
ifTrue: [
pStream nextPutAll: each ; cr ;
nextPutAll: (BaseKeys at: each) ; cr ; cr
]
].
pStream contents outputToPrinter!
remove
"Private - Remove the selected
key from the dictionary."
| assoc |
instIndex isNil
ifFalse: [
assoc := instList at: instIndex.
instList remove: assoc.
object removeKey: assoc key.
BaseKeys removeKey: assoc key.
instIndex := nil.
self
changed: #instVarList with: #restore;
changed: #instance;
changed: #comment
]!
selectInstance: aListPane
"Private - Select the instance variable at
index position anInteger in the list."
instIndex := aListPane selection.
self enableInspectItem.
self changed: #instance:.
self changed: #comment:! !
!SystemDictionary methods !
add: anAssociation
"Answer anAssociation. Add anAssociation to
receiver dictionary. Ensure that the key
is a symbol."
| stream result |
Symbol mustBeSymbol: anAssociation key.
((self includesKey: anAssociation key) not and: [ self == Smalltalk ])
ifTrue: [
stream := WriteStream on: String new.
stream nextPutAll: Username, ' '.
Date today printOn: stream.
stream nextPutAll: ', '.
Time now printOn: stream.
stream nextPutAll: ': '.
result := Prompter
prompt: 'Enter a description for this new global variable: ', anAssociation key
default: ''.
BaseKeys at: anAssociation key put: (stream contents, result)
].
^super add: anAssociation !
inspect
"Open an inspector window on the receiver."
SmalltalkInspector new openOn: self! !
BaseKeys at: #BaseKeys put: 'Document me' !
BaseKeys at: #SmalltalkInspector put: 'Document me' !
BaseKeys at: #Username put: 'Document me' !